<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/layui.js"></script>
    <script src="/html/js/util.js"></script>
    <link rel="stylesheet" href="/html/js/css/layui.css" media="all">
    <title>展示所有用户</title>
</head>
<script>
    window.onload = function () {
        showTable(1)
    }

    async function showTable(pageNo) {
        let params = {
            pageNo: pageNo
        }
        let pages = await ajaxGet("/user/findByPage", params);
        let info = pages.list;
        let str = "";
        for (let i = 0; i < info.length; i++) {
            let obj = info[i];
            str += `<tr>
                <td>${obj.userId}</td>
                <td>${obj.username}</td>
                <td>${obj.sex}</td>
                <td>${obj.money}</td>
                <td>${obj.birthday}</td>
                </tr>`;
        }
        $("bodys").innerHTML = str;

        let cutStr = "<div style='display: flex;justify-content: center'>";
        for (let i = 1; i <= pages.pages; i++) {
            cutStr += `<a style="margin: 10px" href="javascript:showTable(${i})">${i}</a>`
        }
        cutStr += "</div>";
        $("cutPageDiv").innerHTML = cutStr;
    }
</script>


<body>
<div style="display: flex;justify-content: center">
    <div style="display: flex;justify-content: center;padding-top: 30px;width: 800px;">
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="200">
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>用户id</th>
                <th>用户名</th>
                <th>用户性别</th>
                <th>用户工资</th>
                <th>用户生日</th>
            </tr>
            </thead>
            <tbody id="bodys">
            </tbody>
        </table>
    </div>
</div>


<!--页码显示-->
<div id="cutPageDiv">

</div>
<div style="display: flex;justify-content: center">
    <button type="button" class="layui-btn"><a href="/html/userRegister.html">新增用户</a></button>
</div>


</body>
</html>